<?php
// +----------------------------------------------------------------------
// | Freze [ Free ourselves ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.freze.cn All rights reserved.
// +----------------------------------------------------------------------
// | Project: www --- CommonController.php
// +----------------------------------------------------------------------
// | Author: Dashuai <496041341@.qq.com>
// +----------------------------------------------------------------------


namespace Admin\Controller;

use Think\Controller;
class CommonController extends Controller
{
    public function _initialize(){
        $this->init();
    }
    //显示方法
    final protected function display($template=''){
        if($template == '')
            $template = CONTROLLER_NAME;
        echo ($this->fetch($template));
    }

    //用于显示模板的方法
    final protected function fetch($templateFile = CONTROLLER_NAME){
        if(!is_file($templateFile)){
            $templateFile = C("ADMIN_PC_TEMPLATE_PATH")."/".$templateFile."/".ACTION_NAME.C('TMPL_TEMPLATE_SUFFIX');
            if(!is_file($templateFile)){
                throw new \Exception("模板不存在:$templateFile");
            }
        }
        return $this->view->fetch($templateFile);
    }
    public function init(){
        set_init();
        $this->Static = C("ADMIN_PC_TEMPLATE_PATH")."/".C("ADMIN_STATIC_TEMPLATE_PATH");
    }
}